//
//  XLCornerBaseCell.m
//  Current
//
//  Created by 于鹏 on 2017/8/15.
//  Copyright © 2017年 YIVIEW. All rights reserved.
//

#import "XLCornerBaseCell.h"
//#import "XLCornerRadiusView.h"

@implementation XLCornerBaseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setupUI {
    [super setupUI];
    [self.contentView addSubview:self.containerView];
//    [self.contentView sendSubviewToBack:self.containerView];
    [self setupConstraints];
}

- (void)setupConstraints {
    NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:self.containerView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
    [self.contentView addConstraint:topConstraint];
    
    CGFloat constant = 10;
    
    NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem:self.containerView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:constant];
    [self.contentView addConstraint:leftConstraint];
    
    NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem:self.containerView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-constant];
    [self.contentView addConstraint:rightConstraint];
    
    NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem:self.containerView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-constant];
    [self.contentView addConstraint:bottomConstraint];
    
}
- (void)layoutSubviews {
    [super layoutSubviews];
    
}

#pragma mark - Getter 
- (XLCornerRadiusView *)containerView {
    if (!_containerView) {
        _containerView = [[XLCornerRadiusView alloc]init];
        _containerView.translatesAutoresizingMaskIntoConstraints = NO;
//        _containerView.backgroundColor = [UIColor redColor];
    }
    return _containerView;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
